<!DOCTYPE html>
<html>
<head>

    <title></title>
    @if(isset($_GET['MT']))
        @@include('system::admin.Layouts.create-layui-head')
    @else
        @include('system::admin.Layouts.create-layui-head')
    @endif

</head>
<body>
@section('self_extend_css')
@show
<div class="layuimini-container" id="mds_vue">
    <fieldset class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>
                编辑
            </legend>
        </fieldset>
        @section('self_form_top')
        @show
        <form class="layui-form" lay-filter="layui_form">
            <input type="hidden" name="{{$id}}">
            @section('self_input_begin')
            @show
            @foreach ($form as $key => $one)

                {{--判断需不需要间隔线--}}
                @if(isset($one->field) && $one->field == "MDSLine")
                    <div style="width: 95%; margin-left: auto; margin-right: auto; height: 1px; border-top: 1px #c0c6c9 dashed; clear: both; margin-bottom: 15px;"></div>
                    @continue
                @endif

                @switch($one->type)
                    {{--文本框--}}
                    @case(1)
                    <div class="layui-form-item @if($one->isHide == 1) mdsHide @endif {{$one->field}} {{$one->field}}_coat">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span> </label>
                        <div class="layui-input-block">
                            <input type="text" name="{{$one->field}}" lay-verify="{{$one->verify?$one->verify:$one->field}}" autocomplete="off" placeholder="{{$one->name}}" class="layui-input {{$one->field}}">
                        </div>
                    </div>
                    @break
                    {{--数字框--}}
                    @case(16)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <input type="number" name="{{$one->field}}" lay-verify="{{$one->verify}}"
                                   autocomplete="off" placeholder="{{$one->name}}" class="layui-input">
                        </div>
                    </div>
                    @break
                    {{--时间选择--}}
                    @case(2)
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="{{$one->field}}" id="{{$one->field}}" lay-verify="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input {{$one->field}}">
                            </div>
                        </div>
                    </div>
                    @break
                    {{--密码--}}
                    @case(3)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-inline">
                            <input type="password" name="{{$one->field}}" placeholder="请输入密码" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">不写就是不改密码,默认:123456</div>
                    </div>
                    @break
                    {{--范围--}}
                    @case(4)
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="{{$one->field}}[begin]" placeholder="￥" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="{{$one->field}}[end]" placeholder="￥" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    @break
                    {{--下拉--}}
                    @case(5)
                    <div class="layui-form-item {{$one->field}}">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <select class="layui-input layui-unselect" id="{{$one->field}}" name="{{$one->field}}" lay-filter="{{$one->field}}">
                                <template v-for="(site,key) in {{$one->field}}">
                                    <option v-bind:value="key">(> site <)</option>
                                </template>
                            </select>
                        </div>
                    </div>
                    @break
                    {{--多选下拉--}}
                    @case(6)
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                            <div class="layui-input-inline">
                                <select name="{{$one->field}}">
                                    <option value="">请选择问题</option>
                                    <optgroup label="城市记忆">
                                        <option value="你工作的第一个城市">你工作的第一个城市</option>
                                    </optgroup>
                                    <optgroup label="学生时代">
                                        <option value="你的工号">你的工号</option>
                                        <option value="你最喜欢的老师">你最喜欢的老师</option>
                                    </optgroup>
                                </select>
                            </div>
                        </div>
                    </div>
                    @break
                    {{--搜索下拉--}}
                    @case(7)
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                            <div class="layui-input-inline">
                                <select name="{{$one->field}}" lay-verify="">
                                    <option value="">直接选择或搜索选择</option>
                                    <template v-for="(site,key) in {{$one->field}}">
                                        <option v-bind:value="key">(> site <)</option>
                                    </template>
                                </select>
                            </div>
                        </div>

                    </div>
                    @break
                    {{--联动基本不用--}}
                    @case(8)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-inline">
                            <select name="{{$one->field}}">
                                <option value="">请选择省</option>
                                <option value="浙江" selected="">浙江省</option>
                                <option value="你的工号">江西省</option>
                                <option value="你最喜欢的老师">福建省</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <select name="{{$one->field}}">
                                <option value="">请选择市</option>
                                <option value="杭州">杭州</option>
                                <option value="宁波" disabled="">宁波</option>
                                <option value="温州">温州</option>
                                <option value="温州">台州</option>
                                <option value="温州">绍兴</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <select name="{{$one->field}}">
                                <option value="">请选择县/区</option>
                                <option value="西湖区">西湖区</option>
                                <option value="余杭区">余杭区</option>
                                <option value="拱墅区">临安市</option>
                            </select>
                        </div>
                        <div class="layui-form-mid layui-word-aux">此处只是演示联动排版，并未做联动交互</div>
                    </div>
                    @break
                    {{--多选--}}
                    @case(9)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <template v-for="(site,key) in {{$one->field}}">
                                <input type="checkbox" v-bind:value="site.title" v-bind:name="'{{$one->field}}['+key+']'" v-bind:title="site.title">
                            </template>
                        </div>
                    </div>
                    @break
                    {{--普通多选--这个好一些--}}
                    @case(10)
                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <template v-for="(site,key) in {{$one->field}}">
                                <input type="checkbox" v-bind:name="'{{$one->field}}['+key+']'" v-bind:value="site.title" lay-skin="primary" v-bind:title="site.title">
                            </template>
                        </div>
                    </div>
                    @break
                    {{--开关默认关--}}
                    @case(11)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <input checked type="checkbox" name="{{$one->field}}" lay-skin="switch" lay-text="开|关">
                        </div>
                    </div>
                    @break
                    {{--开关默认开废弃--}}
                    @case(12)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="{{$one->field}}" lay-skin="switch" lay-filter="switchTest" lay-text="开|关">
                        </div>
                    </div>
                    @break
                    {{--单选--}}
                    @case(13)
                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <template v-for="(site,key) in {{$one->field}}">
                                <input type="radio" name="{{$one->field}}" v-bind:value="key" v-bind:title="site.title" :checked="site.default==1">
                            </template>
                        </div>
                    </div>
                    @break
                    {{--文本域--}}
                    @case(14)
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" name="{{$one->field}}" class="layui-textarea {{$one->field}}"></textarea>
                        </div>
                    </div>
                    @break
                    {{--富文本--}}
                    @case(15)
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea layui-hide {{$one->field}}" name="{{$one->field}}" lay-verify="content" id="{{$one->field}}"></textarea>
                        </div>
                    </div>
                    @break

                    @case(17)
                    {{--图片上传--}}
                    <div class="layui-form-item mdsImg {{$one->field}}"
                         style="width: 100% !important; float: left; border: solid 1px #1ab394; border-radius: 5px;">

                        <div style="width: 100%; float: left; background: #1ab394;">
                            <label class="layui-form-label" style="width: 80%; color: #ffffff; text-align: left;">{{$one->name}}</label>

                            <button style="float: right; margin-top: 7px; margin-right: 7px;" type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-btn-xs {{$one->field}}_upload">上传照片</button>

                            <label class="layui-form-label" style="width: 100px; color: #ffffff; text-align: left; float: right;">(点击图片删除)</label>

                        </div>

                        <div class="layui-input-block" style="display: none;">
                            <input type="text" name="{{$one->field}}" lay-verify="" placeholder="{{$one->name}}" class="layui-input {{$one->field}}">
                        </div>
                        <div style="padding: 10px; float: left; width: 100%;">

                            {{--例子--}}
                            @if(isset($one->extends['example']))
                            <div style="width: 20%; float: left; height: auto;">
                                    <div style="width: 200px; margin-left: auto; margin-right: auto; margin-top: 10px;">
                                        <div style="width: 200px;" class="docs-pictures image">
                                            <img style="width: 200px;" class="pictures_img" alt="image" src="{{$one->extends['example']}}">
                                        </div>
                                        <div class="file-name text-danger" style="text-align:center; width: 100%; background-color: #f8f8f8; border: 1px solid #e7eaec; padding-top: 20px; padding-bottom: 20px; color: red;">模板
                                        </div>
                                    </div>
                            </div>
                            @endif
                            <div class="{{$one->field}}_img" style="width: 80%; float: left; height: auto;">

                                @if(isset($_GET['MT']))
                                    @@if(isset($this_data['{{$one->field}}'.'17'])) @@foreach($this_data['{{$one->field}}'.'17'] as $k17=>$v17) <img style="width: 150px; height: 150px;" data-field="{{$one->field}}" class="choice_img" src="@{{$v17}}"> @@endforeach @@endif
                                @else
                                    @if(isset($this_data[$one->field.'17']))
                                        @foreach($this_data[$one->field.'17'] as $k17=>$v17)
                                            <img style="width: 150px; height: 150px;" data-field="{{$one->field}}" class="choice_img" src="{{$v17}}">
                                        @endforeach
                                    @endif
                                @endif

                                @if(isset($one->extends['input']))
                                        @foreach($one->extends['input'] as $k17i=>$v17i)
                                <input style="height: 30px; border: 1px solid #e5e6e7; margin-left: 10px;" type="text" name="{{$v17i['field']}}" placeholder="{{$v17i['placeholder']}}" value="">
                                        @endforeach
                                @endif

                            </div>
                        </div>
                    </div>
                    @break
                    @case(18)
                    {{--https://fly.layui.com/extend/tableSelect/#doc--}}
                    {{--只有在循环数据的时候才会不知道--}}
                    <div class="layui-form-item {{$one->field}}_looseCoat">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <input type="hidden" name="{{$one->field}}" id="{{$one->field}}_db">
                            {{--ts-selected确定默认选中那个--这里的表单赋值是后端确定的--}}
                            @if(isset($_GET['MT']))
                            <input ts-selected="@{{isset($this_data['{!! $one->field !!}'])?$this_data['{!! $one->field !!}']:''}}" type="text" name="{{$one->field}}_show" class="layui-input" id="{{$one->field}}_show" value="">
                            @else
                                <input ts-selected="{{isset($this_data[$one->field])?$this_data[$one->field]:''}}" type="text" name="{{$one->field}}_show" class="layui-input" id="{{$one->field}}_show" value="">
                            @endif
                        </div>
                    </div>
                    @break
                    @case(19)
                    {{--省市区详细地址选择--}}
                    <div class="layui-form-item" id="{{$one->field}}-picker">
                        <div class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></div>
                        <div class="layui-input-inline mdsArea mdsSheng" style="width: 100px;">
                            @if(isset($_GET['MT']))
                                <select name="{{$one->field}}_province" class="province-selector" data-value="@{{isset($this_data['{!! $one->field !!}_province'])?$this_data['{!! $one->field !!}_province']:""}}" lay-filter=""> <option value="">请选择省</option> </select>
                            @else
                                <select name="{{$one->field}}_province" class="province-selector" data-value="{{isset($this_data[$one->field.'_province'])?$this_data[$one->field.'_province']:""}}" lay-filter="">
                                    <option value="">请选择省</option>
                                </select>
                            @endif

                        </div>
                        <div class="layui-input-inline mdsArea mdsShi" style="width: 100px;">
                            @if(isset($_GET['MT']))
                            <select name="{{$one->field}}_city" class="city-selector" data-value="@{{isset($this_data['{!! $one->field !!}_city'])?$this_data['{!! $one->field !!}_city']:""}}" lay-filter=""> <option value="">请选择市</option> </select>
                            @else
                                <select name="{{$one->field}}_city" class="city-selector" data-value="{{isset($this_data[$one->field.'_city'])?$this_data[$one->field.'_city']:""}}" lay-filter="">
                                    <option value="">请选择市</option>
                                </select>
                            @endif
                        </div>
                        <div class="layui-input-inline mdsArea mdsQu" style="width: 100px;">
                            @if(isset($_GET['MT']))
                            <select name="{{$one->field}}_county" class="county-selector" data-value="@{{isset($this_data['{!! $one->field !!}_county'])?$this_data['{!! $one->field !!}_county']:""}}" lay-filter=""> <option value="">请选择区</option> </select>
                            @else
                                <select name="{{$one->field}}_county" class="county-selector" data-value="{{isset($this_data[$one->field.'_county'])?$this_data[$one->field.'_county']:""}}" lay-filter="">
                                    <option value="">请选择区</option>
                                </select>
                            @endif
                        </div>

                        <div class="layui-form-item mdsArea address" style="float: left; clear: none;">
                            <input type="text" name="{{$one->field}}_address" lay-verify="" autocomplete="off" placeholder="详细地址" class="layui-input {{$one->field}}_address">
                        </div>

                    </div>
                    @break
                    @case(20)
                    {{--经纬度选择--}}
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$one->name}} <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">

                            <input style="width: 100px; float: left;" class="layui-input {{$one->field}}_longitude"
                                   type="text" readonly name="{{$one->field}}_longitude" id="{{$one->field}}_longitude">
                            <input style="width: 100px; float: left; margin-left: 10px;"
                                   class="layui-input {{$one->field}}_latitude" type="text" readonly name="{{$one->field}}_latitude" id="{{$one->field}}_latitude">

                            <button style="margin-left: 10px;" type="button"
                                    class="layui-btn layui-btn-warm {{$one->field}}_l_and_l">点击获取
                            </button>

                        </div>
                    </div>
                    @break
                    @case(21)
                    {{--一页添加多条信息机制--}}
                    <div class="layui-form-item">
                        <label class="layui-form-label">添加客户服务类别 <span style="color: red;">{{$one->required?'*':''}}</span></label>
                        <div class="layui-input-block">
                            <div v-on:click="add21" class="layui-btn" lay-filter="add21">点击添加</div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <ul>
                                <template v-for="one in all21">
                                    <li style="margin-top: 10px; float: left; width: 100%;">
                                        <template v-for="one2 in customer_service.type21">

                                            <template v-if="one2.field == 'attr_customerType'">
                                                <input v-model="one.attr_customerType" type="text"
                                                       v-bind:placeholder="one2.name"
                                                       v-bind:class="one2.field+' layui-input mds-40'"
                                                       style="width: 40%; float: left;">
                                            </template>
                                            <template v-else>
                                                <input v-model="one.attr_specialRequest" type="text"
                                                       v-bind:placeholder="one2.name"
                                                       v-bind:class="one2.field+' layui-input mds-40'"
                                                       style="width: 40%; float: left; margin-left: 5px;">
                                            </template>

                                        </template>

                                        <button style="margin-left: 10px;" v-on:click="del21" type="button"
                                                class="layui-btn layui-btn-danger"><i class="layui-icon"></i>
                                        </button>

                                    </li>
                                </template>
                            </ul>
                        </div>
                    </div>
                    @break
                    {{--自定义--}}
                    @default
                    {{--待完善--}}
                @endswitch

            @endforeach
            @section('self_input_end')
            @show

            @section('self_form_submit')

                <div class="layui-form-item" style="clear: both; width: 100%;">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="Submit_immediately">立即提交</button>
                        <button type="button" class="layui-btn layui-btn-primary">取消</button>
                    </div>
                </div>
            @show
        </form>
    </fieldset>
</div>

@if(isset($_GET['MT']))
    @@include('system::admin.Layouts.create-layui-top')
@else
    @include('system::admin.Layouts.create-layui-top')
@endif

<script>

    //由于数据更改导致的虚拟 DOM 重新渲染和打补丁
    var mds_vm = new Vue({
        delimiters: ['(>', '<)'],
        el: '#mds_vue',
        data: {
            //这里是为了得到form表单里面的配置信息来动态的获取相关的下拉多选等初始数据
            @foreach ($form as $key_v => $one_v)
                {{--判断需不需要间隔线--}}
                @if($one_v->field == "MDSLine")
                @continue
                @endif
                @if($one_v->type != 18)
                    @if(isset($_GET['MT'])) '{{$one_v->field}}': JSON.parse('@{!! (gettype($form[{{$key_v}}]->extends) == 'array')?json_encode($form[{{$key_v}}]->extends):($form[{{$key_v}}]->extends?$form[{{$key_v}}]->extends:"{}") !!}'), @else
            '{{$one_v->field}}': JSON.parse('{!! (gettype($one_v->extends) == 'array')?json_encode($one_v->extends):($one_v->extends?$one_v->extends:"{}") !!}'),
                    @endif
                @endif
            @endforeach
        },
        mounted() {
            this.layui_function();
        },
        methods: {
            layui_function(){
                layui.use(['tableSelect', 'form', 'layedit', 'laydate', 'jquery', 'layarea','allJs','chinAdmin'], function () {

                    var $ = layui.jquery,form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate,allJs = layui.allJs, layarea = layui.layarea,chinAdmin = layui.chinAdmin;

                    //一一layui对相应的表单进行初始化操作
                    @foreach ($form as $key_l => $one)
                    @if(isset($one->field) && $one->field == "MDSLine")
                    @continue
                    @endif
                    @switch($one->type)
                    //时间选择器
                    @case(2)
                    laydate.render({
                        elem: '#{{$one->field}}',
                        format: 'yyyy-MM-dd HH:mm:ss',
                        type: 'datetime',
                        position: 'fixed',
                        trigger: 'click',
                    });
                    @break

                    @case(15)

                    //创建一个编辑器
                    var editIndex_{{$one->field}} = layedit.build('{{$one->field}}');

                @if(isset($_GET['MT']))
                    @@if(isset($this_data["$one->field"])) layedit.setContent(editIndex_{{$one->field}}, '@{!! $this_data["{{$one->field}}"] !!}'); @@endif
                @else
                @if(isset($this_data["$one->field"]))
                layedit.setContent(editIndex_{{$one->field}}, '{!! $this_data["$one->field"] !!}');
                    @endif
                    @endif

                    @break
                    //上传
                    @case(17)
                    $(".{{$one->field}}_upload").click(function () {

                        var field = '{{$one->field}}';
                        var singleDouble = '{{$one->extends['singleDouble']??"double"}}';
                        var showOld = '{{$one->extends['showOld']??"0"}}';

                        @if(isset($_GET['MT']))
                        var fieldVal = '@{{isset($this_data['{!! $one->field !!}'])?$this_data['{!! $one->field !!}']:''}}';
                        @else
                        var fieldVal = '{{isset($this_data[$one->field])?$this_data[$one->field]:''}}';
                        @endif

                        //iframe层
                        layer.open({
                            type: 2,
                            title: '图片选择',
                            shadeClose: true,
                            shade: 1,
                            area: ['840px', '570px'],
                            content: '/system/upload/index?field='+field+'&fieldVal='+fieldVal+'&singleDouble='+singleDouble+'&showOld='+showOld,
                        });

                    });
                    @break

                    @case(18)

                    //两个18之间的关联等于的function不能直接使用，需要用等于后的。
                    layui.{{$one->field}} = function mds_{{$one->field}}_18(where = {}) {

                        //开始使用
                        var {{$one->field}} = layui.tableSelect;

                        var cols_{{$one->field}} = {!! $one['cols'] !!};

                        /**
                         * https://fly.layui.com/extend/tableSelect/#doc
                         */
                        {{$one->field}}.render({
                            elem: '#{{$one->field}}_show',	//定义输入框input对象 必填
                            checkedKey: '{{$one->extends['foreignKey']}}', //表格的唯一建值，非常重要，影响到选中状态 必填
                            searchKey: '{{$one->extends['searchKey']}}',	//搜索输入框的name值 默认keyword
                            searchPlaceholder: '关键词搜索',	//搜索输入框的提示文字 默认关键词搜索
                            height: '400',  //自定义高度
                            width: '900',  //自定义宽度
                            table: {	//定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
                                url: '/{{$Modules}}/admin/{{$one->extends['class']}}/index?searchType=1',  //这个searchType必须，要不和主列表无法区分
                                cols: [cols_{{$one->field}}],
                                where: where
                            },
                            done: function (elem, data) {   //点击确定的时候执行

                                //如果是多选框
                                if (cols_{{$one->field}}[0].type == "checkbox") {

                                    var showName = "";
                                    var foreignKey = "";

                                    for (var i in data.data) {
                                        showName += data.data[i].{{$one->extends['showName']}}+ ",";
                                        foreignKey += data.data[i].{{$one->extends['foreignKey']}}+ ",";
                                    }

                                    showName = showName.slice(0, showName.length - 1);
                                    foreignKey = foreignKey.slice(0, foreignKey.length - 1);

                                } else {
                                    var showName = data.data[0].{{$one->extends['showName']}};
                                    var foreignKey = data.data[0].{{$one->extends['foreignKey']}};
                                }

                                $("#{{$one->field}}_show").val(showName);
                                $("#{{$one->field}}_db").val(foreignKey);

                                //如果设置了关联其他表格的重载就执行,并读取重载的值
                                @if(isset($one->extends['heavyLoad']))
                                var heavyLoad = {"{{$one->extends['heavyLoadField']}}": data.data[0].{{$one->extends['heavyLoadField']}}};
                                {{$one->extends['heavyLoad']}}(heavyLoad);
                                @endif

                            }
                        });

                    };
                    //如果存在自定义则执行自定义函数
                    typeof mds_{{$one->field}}_18_self === "function" ? mds_{{$one->field}}_18_self(form, $) : layui.{{$one->field}}();
                    @break
                    @case(19)
                    //省市区地区选择
                    layarea.render({
                        elem: '#{{$one->field}}-picker',
                        change: function (res) {
                            //选择结果
                            console.log(res);
                        }
                    });
                    @break
                    @case(20)
                    //经纬度选择
                    $(".{{$one->field}}_l_and_l").click(function () {
                        layer.open({
                            type: 2,
                            title: '点击获取经纬度',
                            shadeClose: true,
                            shade: 0.8,
                            area: ['90%', '90%'],
                            @if(isset($_GET['MT']))
                            content: '/system/map/index?mds={{$one->field}}&longitude=@{{isset($this_data['{!! $one->field !!}'.'_longitude'])?$this_data['{!! $one->field !!}'.'_longitude']:''}}&latitude=@{{isset($this_data['{!! $one->field !!}'.'_latitude'])?$this_data['{!! $one->field !!}'.'_latitude']:''}}',
                            @else
                            content: '/system/map/index?mds={{$one->field}}&longitude={{isset($this_data[$one->field.'_longitude'])?$this_data[$one->field.'_longitude']:''}}&latitude={{isset($this_data[$one->field.'_latitude'])?$this_data[$one->field.'_latitude']:''}}',
                            @endif

                        });
                    });
                    @break
                    @default
                    @endswitch
                    @endforeach

                    //二表单初始简单赋值这里很重要
                    form.val('layui_form', {
                        @foreach ($this_data as $k => $one_l)
                        @if (gettype($one_l) === 'array')
                        @if(key($one_l) === 'type21')
                        @continue
                        @endif
                        //如果是数组
                        @foreach ($one_l as $kt => $one_lt)
                        //普通多维,二维里面的每个值都显示出来
                        @if(isset($_GET['MT']))
                        "{{$k}}[{{$kt}}]": '@{!! $this_data["{{$k}}"]["{{$kt}}"]??"" !!}',
                        @else
                        "{{$k}}[{{$kt}}]": '{!! $one_lt !!}',
                        @endif

                            @endforeach
                            @else
                            @if ($one_l === 'on')
                        "{{$k}}": true,
                        @elseif ($one_l === 'off')
                        "{{$k}}": false,
                        @else
                            @if ($k == 'password')
                        "{{$k}}": '',                               //如果是密码就不赋值
                        @else
                            @if(isset($_GET['MT']))
                        "{{$k}}": '@{!! isset($this_data["{{$k}}"])?$this_data["{{$k}}"]:"" !!}',
                        @else
                        "{{$k}}": '{!! $one_l !!}',                 //这里是所有的通用赋值
                        @endif

                        @endif
                        @endif
                        @endif
                        @endforeach
                    });

                    //二二Vue复杂赋值，这个只对一对多的21号起作用
                    @foreach ($this_data as $k => $one_l)
                        @if (gettype($one_l) === 'array')
                        @if(key($one_l) === 'type21')

                        @if(isset($_GET['MT']))
                        mds_vm.all21 = JSON.parse('@{!! json_encode($this_data['{{$k}}']['type21']) !!}');
                    @else
                        mds_vm.all21 = JSON.parse('{!! json_encode($one_l['type21']) !!}');
                    @endif

                    @continue
                    @endif
                    @endif
                    @endforeach

                    //form表单自定义验证
                    form.verify({
                        @foreach ($form as $one)
                            @if(isset($one->field) && $one->field == "MDSLine")
                            @continue
                            @endif
                            @switch($one->type)
                            @case(-100)
                            @break
                            @default
                            @if($one->verify_ext != '')
                            {{$one->field}}: function (value) {
                            var verify_ext = {!! $one->verify_ext !!};
                            for (var i in verify_ext) {
                                if (i == 'length') {
                                    switch (verify_ext[i].condition) {
                                        case "<":
                                            if (value.length < verify_ext[i].num) {
                                                return verify_ext[i].info;
                                            }
                                            break;
                                        case ">":
                                            if (value.length > verify_ext[i].num) {
                                                return verify_ext[i].info;
                                            }
                                            break;
                                        default:

                                    }
                                }
                            }
                        },
                        @endif
                        @endswitch
                        @endforeach
                    });

                    //放到layui统一全局
                    layui.formSubmit = function formSubmit(data){

                        //这里对各种疑难杂症数据进行整理。
                        @foreach ($form as $one)

                            @if(isset($one->field) && $one->field == "MDSLine")
                            @continue
                            @endif

                            @if ($one->type == 11 || $one->type == 12)
                            data.field.{{$one->field}} = data.field.{{$one->field}} ? 'on' : 'off';
                        @endif
                            @if ($one->type == 15)
                            data.field.{{$one->field}} = layedit.getContent(editIndex_{{$one->field}});//取整个值
                        @endif
                        @if ($one->type == 21)
                        var attr_end = {};
                        var attr_all = [];
                        var attr_customerType = [];
                        var attr_specialRequest = [];

                        $(".attr_customerType").each(function (a, b) {
                            attr_customerType.push($(this).val());
                        });

                        $(".attr_specialRequest").each(function (a, b) {
                            attr_specialRequest.push($(this).val());
                        });

                        for (var i in attr_customerType) {
                            var one = {};
                            one.attr_customerType = attr_customerType[i];
                            one.attr_specialRequest = attr_specialRequest[i];
                            attr_all.push(one);
                        }

                        attr_end.type21 = attr_all;

                        data.field.{{$one->field}} = JSON.stringify(attr_end);
                        @endif
                        @endforeach

                        //链接上传过来的默认值
                        @if(isset($_GET['MT']))
                            data.field.default = '@{!! $i_i !!}';
                        @else
                            data.field.default = '{!! $i_i !!}';
                        @endif

                        allJs.MDSAjax("/{{$Modules}}/admin/{{$class}}/create",data.field,function(data){
                            layer.msg(data.msg);
                            if (data.code == 200) {
                                var f_layer = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(f_layer);
                                parent.layui.table.reload('currentTableId');    //单独打开没有上级也没会报错，不用管。
                            }
                            return false;
                        });

                        return false;

                    };

                    //son扩展操作js
                    typeof layui_extend_js === "function" ? layui_extend_js(layui) : false;

                    //通用调用
                    chinAdmin.create(layui);

                });
            },
            add21: function () {
                mds_vm.all21.push(1);
            },
            del21: function () {
                mds_vm.all21.splice(-1, 1);
            },
        },
        updated: function () {                          //这个是为了vue的双向绑定。
            layui.use('form', function () {
                layui.form.render('select');
            });
        },
    });

</script>

@section('self_extend_js')
@show

</body>
</html>
